create procedure wp_LatestVersion
	@ObjectID int,
	@State int
as
	declare @objectstate int
	declare @infostate int
	declare @branchid int

	select @infostate = max(State) from Info where State <= @State
	select @branchid = BranchID from Info where State = @infostate

	select @objectstate = dbo.wp_GetObjectState(@ObjectID, @branchid, @State-1)

	select @objectstate